#!/usr/bin/env node

const Dog = require('./02-dog.js')

const taidi = new Dog('taidi',4),
      zangao = new Dog('zangao',6);

taidi.on('bark',onBark);
zangao.on('bark',onBark);

function onBark(){
  console.log(`name:${this.name},energy:${this.energy}`);
}

setTimeout(()=>{
  console.log('taidi eat food');
  taidi.energy=3;
  },1000);
